<?php
class DataMapper {

	static function Map($varArray, DBListItem $item, $prefix) {
		
		if(is_array($varArray)) {
		
			while(list($key, $value) = each($varArray)) {
				
				if(substr($key, 0, strlen($prefix))==$prefix) {
					
					$name = substr($key, strlen($prefix)+1);
					
					if($item->hasField($name)) { $item->$name = $value; /* echo "mapped value '$value' to '$name'"; */}
					
				}
				
			}
			
		}
		else {
			//No Array
		}
				
	}
	
}
?>